<?php
include("../include/config.inc.php");
include("userlogincheck.php");

$sql="select * from ".tableprefix."store where member_id=$userid";
$result=$db->query($sql);
$row=$db->fetch_array($result);
$store_id=$row["store_id"];
$amount=$row["store_credit"];
$db->free_result($result);

if($amount==0){
	echo("<script type='text/javascript'>alert('保证金金额为0.00元，无需退还。');history.back(-1);</script>");
	exit;
}

$cashtype='保证金';
$createtime=date("Y-m-d H:i:s");
$ip=getIP();
$status='0';
$flag='T';
$sql="insert into ".tableprefix."cashout(amount,cashtype,storeid,userid,createtime,ip,status,flag)values('$amount','$cashtype','$store_id','$userid','$createtime','$ip','$status','$flag')";
$db->query($sql);
if(!$db->error())
	{
		$sql="update ".tableprefix."store set grade_id='0' and store_credit='0' where store_id=$store_id";	
		$db->query($sql);
	}
	else
	{
		PhpBox('数据库出错！');
		GotoPage('../index.php');
		$db->close();
		exit;
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>订戏会</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=9,Chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="stylesheet" type="text/css" href="../css/public.css">
<link rel="stylesheet" type="text/css" href="../css/publish.css">
</head>

<body>
<div id="publish-store">
	<div class="publish-store-img"><img src="../images/store_w.png"></div>
	<div class="publish-store-btitle">保证金退还已成功提交</div>
	<div class="publish-store-stitle">此过程中如还有交易进行将待交易完成后退还</div>
	<a href="mywallet.php"><div class="publish-store-sumbit">返回</div></a>
</div>



<footer id="bar-fixed">
	<a href="../../mobile" class="tab-item"><i class="icon-tabbar bar-home"></i>首页</a>
	<a href="../category.php" class="tab-item"><i class="icon-tabbar bar-message"></i>分类</a>
	<a href="../publish" class="tab-item active"><i class="icon-tabbar bar-publish2"></i>发布</a>	
	<a href="../user" class="tab-item"><i class="icon-tabbar bar-user"></i>我</a>
</footer>
</body>
</html>